<html><head>
<link rel="stylesheet" href="style.css" type="text/css">
<meta content="text/html; charset=iso-8859-1" http-equiv="Content-Type">
<link rel="Start" href="index.html">
<link title="Index of values" rel=Appendix href="index_values.html">
<link title="Index of modules" rel=Appendix href="index_modules.html">
<link title="Vmg" rel="Chapter" href="Vmg.html"><title>Vmg</title>
</head>
<body>
<code class="code"></code><table><tr><td></td><td><span class="comment">(** *)</span></td></tr></table><code class="code"><br>
<br>
</code><table><tr><td></td><td><span class="comment">(** The constant greek pi*)</span></td></tr></table><code class="code"><br>
<span class="keyword">let</span>&nbsp;pi&nbsp;=&nbsp;3.14159265;;<br>
<br>
</code><table><tr><td></td><td><span class="comment">(** Convert the angle expressed in degrees
  to an angle as part of 2*.pi *)</span></td></tr></table><code class="code">&nbsp;<br>
<span class="keyword">let</span>&nbsp;angle_in_degrees_to_angle_in_float&nbsp;(angle:int)=&nbsp;<br>
&nbsp;&nbsp;<span class="comment">(*&nbsp;We&nbsp;leave&nbsp;the&nbsp;code&nbsp;as&nbsp;it&nbsp;stands,<br>
&nbsp;&nbsp;as&nbsp;it&nbsp;is&nbsp;optimized&nbsp;by&nbsp;the&nbsp;compiler&nbsp;*)</span><br>
&nbsp;&nbsp;((2.&nbsp;*.&nbsp;pi)/.360.)&nbsp;*.&nbsp;(float_of_int&nbsp;angle)<br>
;;<br>
<br>
</code><table><tr><td></td><td><span class="comment">(** The computation of the vmg.
  We export only this value from the module
  @param goodheading the wished direction,
  @param speed the actual speed, 
  @param heading the actual direction.
  @return the speed in the direction goodheading.
*)</span></td></tr></table><code class="code"><br>
<br>
<span class="keyword">let</span>&nbsp;vmg&nbsp;(heading,speed,goodheading)&nbsp;=<br>
&nbsp;&nbsp;<span class="keyword">let</span><br>
&nbsp;&nbsp;&nbsp;&nbsp;int_angle&nbsp;=&nbsp;abs&nbsp;(heading&nbsp;-&nbsp;goodheading)<br>
&nbsp;&nbsp;<span class="keyword">in</span><br>
&nbsp;&nbsp;<span class="keyword">let</span><br>
&nbsp;&nbsp;&nbsp;&nbsp;float_angle&nbsp;=&nbsp;angle_in_degrees_to_angle_in_float&nbsp;int_angle<br>
&nbsp;&nbsp;<span class="keyword">in</span><br>
&nbsp;&nbsp;&nbsp;&nbsp;(cos&nbsp;float_angle)*.speed;;<br>
</code></body></html>